package com.example.springbootdemo.validation;


import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

import java.util.Arrays;
import java.util.List;

public class EpsgValidator implements ConstraintValidator<ValidEpsg, String> {

    private static final List<String> VALID_EPSG_CODES = Arrays.asList(
            "EPSG:4326", "EPSG:4490", "EPSG:4524"
    );

    @Override
    public boolean isValid(String epsg, ConstraintValidatorContext context) {
        if (epsg == null) {
            return true; // 允许为空，使用默认值
        }
        return VALID_EPSG_CODES.contains(epsg);
    }
}